<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2021/10/9
 * Time: 13:48
 */

namespace app\admin\controller;


use think\Db;

class Groupchat extends Base
{
    /**
     * 群聊列表
     * @return mixed|\think\response\Json
     */
    public function index(){
        if(request()->isAjax ()){
            $Nowpage = input('page') ? input('page') : 1;
            $limits = input("limit") ? input("limit") : 10;
            $count = Db::name('user_group_chat')->count();// 获取总条数
            $lists = Db::name('user_group_chat')
                ->field('gc_id, gc_name, gc_time, gc_status, gc_notice')
                ->page($Nowpage,$limits)
                ->order('gc_last_time desc')
                ->select();
            return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
        }
        return $this->fetch();
    }
    
    /**
     * 聊天详情
     * @return mixed
     */
    public function chatDetail(){
        $gc_id = input('gc_id');
        $info = Db::table('up_user_group_chat_info')
            ->where('chat_gc_id', $gc_id)
            ->field('chat_send_phone, chat_content, chat_type, chat_time')
            ->order('chat_time asc')
            ->select();
        return $this->fetch('groupchat/chatdetail', ['info' => $info]);
    }
}